package com.example.homework.adapter;

import android.support.annotation.NonNull;


import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager2.adapter.FragmentStateAdapter;


import java.util.List;

public class ViewPagerAdapter extends FragmentStateAdapter {
    String titleArr[];
    List<Fragment> fragmentList;
    public ViewPagerAdapter(@NonNull FragmentActivity fragmentActivity,
    List<Fragment> list,String[] titleArr) {
        super(fragmentActivity);
        fragmentList=list;
        this.titleArr=titleArr;
    }

    @NonNull
    @Override
    public Fragment createFragment(int position) {
        return fragmentList.get(position);
    }

    @Override
    public int getItemCount() {
        return fragmentList.size();
    }
    public CharSequence getTitle(int position){
        return  titleArr[position];
    }
}
